# -*- codeing = utf-8 -*-
# @Time : 2023/2/27 10:34
# @Author : 小马
# @File: pythonExtend.py
# @Software : PyCharm



#继承的用法
import pygame.sprite
import random

class pythonExtend(pygame.sprite.Sprite):
    def __init__(self):
        super(pythonExtend,self).__init__()
        self.image=pygame.image.load('material/b8.1.PNG').convert_alpha()
        self.images=[pygame.image.load('material/b8.{:d}.png'.format(i)).convert_alpha() for i in range(1,7)]
        self.rect = self.images[0].get_rect()
        t = random.randint(1, 5)
        self.rect.top = t * 100

        self.speed = 6
        self.rect.left = 1200
        self.blood=1


    def update(self, *args):
      if self.blood>0:
        self.image=self.images[args[0]%len(self.images)]

        if self.rect.left<300:
            self.kill()
        else:
            self.rect.left -= self.speed
      else :
          self.kill()